package org.example.common.configs.queue.disruptor;

import com.lmax.disruptor.ExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import com.google.common.base.Throwables;
/**
 * @author weigang
 * @create 2022-07-11 14:29
 */
@Slf4j
public class DisruptorWorkerExceptionHandler  implements ExceptionHandler<DisruptorEvent> {

    @Override
    public void handleEventException(Throwable ex, long sequence, DisruptorEvent event) {
        log.warn("Disruptor handle Event Failed, event:{}, ex:{}", event, Throwables.getStackTraceAsString(ex));
    }

    @Override
    public void handleOnStartException(Throwable ex) {
        throw new IllegalStateException(ex);
    }

    @Override
    public void handleOnShutdownException(Throwable ex) {
        throw new IllegalStateException(ex);
    }

}
